<!--
 * @Author: lixb
 * @Date: 2020-08-19 10:29:30
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-09-26 16:28:38
 * @Descripttion: 人员统计模块
-->
<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span class="modul-title">
          <img
            src="@/assets/img/人员统计1.png"
            style="height: 25px;width: 25px;margin-right: 10px;"
          />
          <span>人员统计</span>
        </span>
        <div class="title-right" type="text" @click="goStaffInfo()">
          人员管理
        </div>
      </div>
      <div class="text item personnel-statistics-main">
        <p class="title">在职员工（人）</p>
        <p class="num">{{ organizationWorkingCount }}</p>
        <el-button
          type="primary"
          style="background: #3771E9;color: white;width: 100px;height: 40px"
          @click="goDistribute()"
        >
          发福利
        </el-button>
      </div>
      <p class="footer-text">
        本月在职/离职：{{ organizationWorkingCount }} /
        {{ organizationAbortCurrentMonthCount }}
      </p>
    </el-card>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex';
  import { getLocalData } from '@/utils/localStore';
  import { hasMenu } from '@/plugins/hasMenu';
  import { getOrganizationStaffCountMap } from '@/api/home';
  export default {
    data() {
      return {
        organizationWorkingCount: '',
        organizationAbortCurrentMonthCount: '',
      };
    },
    computed: {
      ...mapGetters('user', ['userInfo']),
    },
    activated() {
      this.getStaffInfo();
    },
    methods: {
      getStaffInfo() {
        let params = {
          organizationId: this.userInfo.organId,
        };
        getOrganizationStaffCountMap(params).then(res => {
          this.organizationAbortCurrentMonthCount = res.data.organizationAbortCurrentMonthCount;
          this.organizationWorkingCount = res.data.organizationWorkingCount;
        });
      },
      goStaffInfo() {
        if (hasMenu('WALFARE-ENTER-YGXXCX')) {
          this.$router.push('/staffInfo');
        } else {
          this.$message.error('暂无操作权限！');
        }
      },
      goDistribute() {
        if (getLocalData('authKeys') && getLocalData('authKeys')['WALFARE-XXKZHGL-CKHK']) {
          this.$router.push('/careCard/distribute');
        } else {
          this.$message.error('暂无操作权限！');
        }
      },
    },
  };
</script>

<style lang="scss" scoped>
  .el-card.is-always-shadow {
    border-radius: 10px;
  }
  .title-right {
    float: right;
    font-size: 14px;
    color: #bcbbbe;
    border: 1px solid #bcbbbe;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
  }
  .personnel-statistics-main {
    text-align: center;
    .title {
      font-size: 12px;
    }
    .num {
      font-size: 32px;
      color: #697bff;
      font-weight: bold;
    }
  }
  .footer-text {
    float: right;
    color: #868686;
    font-size: 12px;
  }
  .modul-title * {
    font-weight: bold;
    font-size: 18px;
    display: inline-block;
    vertical-align: middle;
  }
  .box-card {
    margin-top: 10px;
  }
</style>
